<template>
	<div class="bg">
		<uni-nav-bar :fixed="true" title="信息详情" background-color="#5C7FF5" status-bar @clickLeft="back" :dark="true"
			left-icon="left">

		</uni-nav-bar>

		<div>
			<div class="p30 bgwhite">
				<div class="infoItem">
					<div class="infoItem_label">运营单位</div>
					<div class="infoItem_content">{{ form.org }}</div>
				</div>
				<div class="infoItem">
					<div class="infoItem_label">所属电站</div>
					<div class="infoItem_content">{{ form.station }}</div>
				</div>
				<div class="infoItem noboderbottom">
					<div class="infoItem_label">电压等级</div>
					<div class="infoItem_content">{{ form.voltage }}</div>
				</div>

			</div>
			<div class="line"></div>
			<div class="p30 bgwhite">
				<div class="infoItem">
					<div class="infoItem_label">设备名称</div>
					<div class="infoItem_content">{{ form.deviceName }}</div>
				</div>
				<div class="infoItem">
					<div class="infoItem_label">设备类型</div>
					<div class="infoItem_content">{{ form.deviceType }}</div>
				</div>
				<div class="infoItem">
					<div class="infoItem_label">缺陷部位</div>
					<div class="infoItem_content">{{ form.partsType }}</div>
				</div>
				<div class="infoItem">
					<div class="infoItem_label">缺陷描述</div>
					<div class="infoItem_content">{{ form.description }}</div>
				</div>
				<div class="infoItem">
					<div class="infoItem_label">分类依据</div>
					<div class="infoItem_content">{{ form.classificationBasis }}</div>
				</div>
				<div class="infoItem">
					<div class="infoItem_label">缺陷性质</div>
					<div class="infoItem_content">{{ form.level }}</div>
				</div>
				<div class="infoItem">
					<div class="infoItem_label">缺陷发现人员</div>
					<div class="infoItem_content">{{ form.username }}</div>
				</div>
				<!-- <div class="infoItem noboderbottom" v-if="rules ==1">
  <div class="infoItem_label">巡检人员</div>
  <div class="infoItem_content">{{ form.username }}</div>
  </div> -->
				<div class="infoItem noboderbottom">
					<div class="infoItem_label">巡检时间</div>
					<div class="infoItem_content">{{ form.time }}</div>
				</div>
			</div>
			<div class="line"></div>
			<div class="p30 bgwhite">
				<div class="infoItem">
					<div class="infoItem_label">设备型号</div>
					<div class="infoItem_content">{{ form.model }}</div>
				</div>
				<div class="infoItem">
					<div class="infoItem_label">生产厂家 </div>
					<div class="infoItem_content">{{ form.manufacturer }}</div>
				</div>
				<div class="infoItem noboderbottom">
					<div class="infoItem_label">投运日期</div>
					<div class="infoItem_content">{{ form.date }}</div>
				</div>
			</div>
			<div class="line"></div>
			<div class="p50 bgwhite" style="margin-top: 16rpx;" v-if="fileLists">
				<uni-file-picker limit="1" multiple @success="success" @progress="progress" @fail="fail"
					@delete="deletes" :disabled="true" @select="select" :readonly="true" :del-icon="true"
					v-model="fileLists">
					<img src="../../static/img/isAdd.png" style="width: 72rpx;height: 60rpx;" alt="">

				</uni-file-picker>
			</div>

			<div style="box-shadow: 0px 3px 6px 1px rgba(0,0,0,0.16);box-sizing: border-box;margin-bottom: 16rpx;display: flex;align-items:center;justify-content: space-between;width: 100%;height: 88rpx;background-color: white;font-weight: 500;font-size: 28rpx;color: #262626;line-height: 88rpx;letter-spacing: 1rpx;padding:0rpx 50rpx;margin-top: 16rpx;"
				@click="toshenhezhedie(item,index)" v-for="(item,index) in form.defectRecodes" :key="index">
				<div>{{'消缺审核信息'+(index+1)}}</div>
				<img style="font-size: 40rpx;width: 20rpx;height: 40rpx;" src="../../static/img/tu.png" alt="" />
			</div>
			<!-- 	<div style="padding-bottom: 60rpx;" v-if="form.status && form.status == '已消缺'">
				<div class="titles">消缺信息</div>
				<div class="p50 bgwhite" style="margin-top: 16rpx;" v-if="fileLists1">
					<uni-file-picker limit="1" multiple @success="success" @progress="progress" @fail="fail"
						@delete="deletes" :disabled="true" @select="select" :readonly="true" :del-icon="true"
						v-model="fileLists1">
						<img src="../../static/img/isAdd.png" style="width: 72rpx;height: 60rpx;" alt="">
					</uni-file-picker>
				</div>
				<div class="p50 bgwhite">
					<div class="infoItem">
						<div class="infoItem_label">消缺人员</div>
						<div class="infoItem_content">{{ form.solveName }}</div>
					</div>
					<div class="infoItem">
						<div class="infoItem_label">消缺时间</div>
						<div class="infoItem_content">{{ form.solveTime }}</div>
					</div>
					<div class="infoItem">
						<div class="infoItem_label">备注</div>
						<div class="infoItem_content">{{ form.solveRemarks }}</div>
					</div>
				</div>
			</div> -->
			<div class="addBtn" v-if="form.status !='已消缺'">
				<div v-if="(form.openid== isMyself &&sameDay && rule =='inspection') "
					:class="{'bts':true,'edit':true,'oneEdit':(form.username== isMyself)&& rule=='inspection'  &&sameDay} "
					@click="toEdit">
					修改
				</div>

				<div v-if="rule =='admin'" :class="{'bts':true,'edit':true  } " @click="toEdit"
					style="width: 650rpx;height: 80rpx;">
					修改
				</div>
				<div v-if="rule =='inspection' && form.openid== isMyself &&sameDay " class="bts del" @click="toDel">
					删除
				</div>
				<div :class="{bts:true, xq:rule != 'admin'}" v-if="rule=='solve'" @click="toXq">
					消缺
				</div>
			</div>

		</div>

		<!-- 删除 -->
		<dialogs ref="dialog" :datas="deldatas" :type="'public'">

		</dialogs>
	</div>
</template>

<script>
	import {
		nowDay
	} from "@/utils/filters"
	import dialogs from "@/components/dialog.vue";
	import {
		COM_URL,
		IMG_URL
	} from "@/utils/config";
	import {
		findDefectByCode
	} from '@/utils/http'
	export default {
		onLoad(query) {
			this.getInfo(query.code)
			this.rule = uni.getStorageSync('userInfo').role
			this.isMyself = uni.getStorageSync('openid')
			this.comeForm = query.u
		},

		onShow() {
			this.rules = uni.getStorageSync('userInfo').userId

		},

		components: {
			dialogs
		},

		data() {
			return {
				form: {},
				fileLists: [],
				fileLists1: [],
				deldatas: [],
				rule: '',
				isMyself: '',
				sameDay: null,
				comeForm: "",
				rules: "",

			};
		},

		methods: {
			toshenhezhedie(item, index) {
				// uni.navigateTo({
				// 	url: '/pages/order/shehezhedie?info=' + encodeURIComponent(JSON.stringify(item)) + '&num' +
				// 		encodeURIComponent(JSON.stringify(index))
				// })
				uni.navigateTo({
					url: '/pages/order/shehezhedie?info=' + encodeURIComponent(JSON.stringify(item)) +
						`&num=${index}`
				})
			},
			toXq() {
				uni.navigateTo({

					url: '/pages/order/xiaoqueright?code=' + this.form.code
				})
			},
			back() {
				uni.navigateBack({
					delta: 1 // 默认值是1，表示回退到上一页，如果要回退多级可以设置大于1的数值
				});
			},

			// 删除
			toDel() {
				this.deldatas = [this.form.id]
				this.$refs.dialog.$refs.inputDialog.open();


			},
			toEdit() {
				uni.navigateTo({
					url: '/pages/order/infoEdit?code=' + this.form.code
				})

			},
			// 消缺
			toright() {
				uni.navigateTo({
					url: '/pages/order/xiaoqueright?code=' + this.form.code
				})
			},
			getInfo(code) {
				findDefectByCode({
					code
				}).then(res => {
					this.form = res.result
					this.sameDay = nowDay() == this.form.time.split(' ')[0]
					if (this.form.pic && this.form.pic.length > 0) {
						this.form.pic.forEach(item => {
							this.fileLists.push({
									url: IMG_URL + item.path,
									code: item.code,
									id: item.id,
									fileID: item.code,
									path: item.path,
									paths: item.paths,
								}

							)
						})
					}
					if (this.form.pics && this.form.pics.length > 0) {
						this.form.pics.forEach(item => {
							this.fileLists1.push({
									url: IMG_URL + item.path,
									code: item.code,
									id: item.id,
									fileID: item.code,
									path: item.path,
									paths: item.paths,
								}

							)
						})
					}
				})
			},

		}
	};
</script>

<style scoped lang="scss">
	.bg {
		box-sizing: border-box;
		// padding:0rpx 50rpx;
		height: 100%;
		background: #F5F6F8;

		.noboderbottom {
			border-bottom: none !important;
		}

		.infoItem {
			padding: 20rpx 0;
			display: flex;
			justify-content: space-around;
			border-bottom: 1rpx solid #b1aeae;

			.infoItem_label {
				width: 200rpx;
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 500;
				font-size: 28rpx;
			}

			.infoItem_content {
				margin-left: 80rpx;
				flex-wrap: wrap;
				text-align: right;
				flex: 1;
				font-family: Source Han Sans CN, Source Han Sans CN;
				font-weight: 400;
				font-size: 28rpx;
				color: #262626;
			}
		}

		.line {
			height: 16rpx;
		}
	}

	.pImg {
		margin-top: 20rpx;
		width: 298rpx;
		height: 212rpx;
	}

	.hasFlex {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
	}

	.addBtn {
		margin-top: 30rpx;
		padding-bottom: 30rpx;
		line-height: 80rpx;

		display: flex;
		justify-content: space-around;

		.bts {
			text-align: center;
			width: 300rpx;
			height: 80rpx;

			box-shadow: 0rpx 3rpx 6rpx 1rpx rgba(0, 0, 0, 0.16);
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: 500;
			font-size: 36rpx;

		}

		.xq {
			width: 600rpx !important;
			background: #5C7FF5 !important;
			color: #FFFFFF !important;
		}

		.edit {
			background: #5C7FF5;
			color: #FFFFFF;
		}

		.edit.oneEdit {
			width: 600rpx;
		}

		.del {
			background: #FFFFFF;
			box-shadow: 0rpx 3rpx 6rpx 1rpx rgba(0, 0, 0, 0.16);
			border-radius: 12rpx 12rpx 12rpx 12rpx;
			border: 1rpx solid #707070;
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: 500;
			font-size: 36rpx;
			color: #2B2B2B;
		}
	}
</style>
<style scoped>
	.p30 {
		padding: 20rpx 30rpx;

	}

	.p50 {
		padding: 20rpx 50rpx;

	}

	.bgwhite {
		background: white;
		box-shadow: 0rpx 3rpx 6rpx 1rpx rgba(0, 0, 0, 0.16);
	}

	.bg>>>.uni-nav-bar-text {
		font-size: 35rpx;
	}

	.bg>>>.icon-del-box {
		display: none;
		width: 40rpx;
		height: 40rpx;
		background-color: red;

	}

	.bg>>>.icon-del {
		width: 20rpx;
		height: 4rpx;
	}

	.titles {
		font-family: Source Han Sans CN, Source Han Sans CN;
		font-weight: bold;
		font-size: 30rpx;
		color: #313131;
		margin-top: 10rpx;
		box-sizing: border-box;
		padding-left: 40rpx;

	}
</style>